﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Nova_BLL
{
    public class TBase_Position
    {
        DataSet ds = null;
        Nova_DAL.TBase_Position Nova_DAL_TBase_Position = new Nova_DAL.TBase_Position();

        ///<summary>
        ///获取货位信息
        ///</summary>
        ///<param name="lbl_LaneNo">巷道号</param>
        ///<returns>返回DataTable</returnss>
        ///Writer：[王成友]
        ///Create Date： [2010-7-1]
        ///</summary>
        public DataTable DTableTBase_Position(string lbl_LaneNo)
        {
            DataTable myTable = new DataTable();
            try
            {
                myTable = Nova_DAL_TBase_Position.DTableTBase_Position(lbl_LaneNo);
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return myTable;

        }

        ///<summary>
        ///获取PID
        ///</summary>
        ///<param name="PID">自增长字段</param>
        ///<returns>返回PID</returnss>
        ///Writer：[王成友]
        ///Create Date： [2010-7-2]
        ///</summary>

        public string GetiPID(Nova_MOD.TBase_Position TBase_Position)
        {
            string PID = "";
            try
            {
                PID = Nova_DAL_TBase_Position.GetiPID(TBase_Position);
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return PID;
        }

        /// <summary>
        /// 修改货位信息
        /// </summary>
        /// <param name="BtnPermit"></param>
        /// <returns>返回i</returns>
        /// Writer：[夏鑫]
        ///Create Date： [2010-7-1]
        public string UpdatePosition(string iPID, int iPos_State)
        {
            string strErrMsg = "";
            try
            {
                strErrMsg = Nova_DAL_TBase_Position.UpdatePosition(iPID, iPos_State);
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return strErrMsg;
        }


        /// <summary>
        /// 修改货位表GridView的宽度和高度
        /// </summary>
        /// <param name="">width,height</param>
        /// <returns>返回1成功，0失败</returns>
        /// Writer：[王成友]
        ///Create Date： [2010-7-2]
        public int iBackGVStyle(string strWidth, string strHeight, string strTableName, string strUserNo)
        {
            int iFlag = 0;
            try
            {
                iFlag = Nova_DAL_TBase_Position.iBackGVStyle(strWidth, strHeight, strTableName, strUserNo);
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return iFlag;
        }

        /// <summary>
        /// 返回货位表GridView的宽度和高度
        /// </summary>
        /// <param name="">width,height</param>
        /// <returns>返回宽，高</returns>
        /// Writer：[王成友]
        ///Create Date： [2010-7-2]
        public DataSet getGVStyle(string strTableName, string strUserNo)
        {
            try
            {
                ds = Nova_DAL_TBase_Position.getGVStyle(strTableName, strUserNo);
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return ds;
        }

        /// <summary>
        /// 返回货位表中的物品存储分类信息
        /// </summary>
        /// <param name="">巷道iLane</param>
        /// <returns>物品存储分类信息</returns>
        /// Writer：[王成友]
        ///Create Date： [2010-7-8]

        public DataSet DataListTypeOfStorage(int iLaneID)
        {
            try
            {
                ds = Nova_DAL_TBase_Position.DataListTypeOfStorage(iLaneID);
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return ds;
        }


        /// <summary>
        /// 返回货位表中品质状态
        /// </summary>
        /// <param name="TBase_Position"></param>
        /// <returns></returns>
        /// Writer：[夏鑫]
        ///Create Date： [2010-7-09]
        public string getTypeOfState(Nova_MOD.TBase_Position TBase_Position, string ColField)
        {
            string strTypeOfState = "";
            try
            {
                strTypeOfState = Nova_DAL_TBase_Position.getTypeOfState(TBase_Position, ColField);
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return strTypeOfState;
        }

        /// <summary>
        /// 修改货位基本信息表中货位状态
        /// </summary>
        /// <param name="TBase_Position"></param>
        /// <param name="ColField">字段名称</param>
        /// <returns></returns>
        /// Writer：[夏鑫]
        ///Create Date： [2010-7-09]
        public int UpdateTBase_Position(Nova_MOD.TBase_Position TBase_Position, string ColField, string strState)
        {
            int iFlag = 0;
            try
            {
                iFlag = Nova_DAL_TBase_Position.UpdateTBase_Position(TBase_Position, ColField, strState);

            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return iFlag;
        }

        /// <summary>
        /// 修改货位信息 wx 项目  其他项目不需要
        /// </summary>
        /// <param name="iPID"></param>
        /// <param name="iPos_State"></param>
        /// <returns></returns>
        public string UpdatePositionForWX(string iPID, int iPos_State)
        {
            string strErrMsg = "";
            try
            {
                strErrMsg = Nova_DAL_TBase_Position.UpdatePositionForWX(iPID, iPos_State);
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return strErrMsg;
        }

        /// <summary>
        /// 获取货位表的PID 新增库区条件
        /// </summary>
        /// <param name="TBase_Position"></param>
        /// <param name="lbl_ZoneID"></param>
        /// <returns></returns>
        public string GetiPID(Nova_MOD.TBase_Position TBase_Position, string lbl_ZoneID)
        {
            string PID = "";
            try
            {
                PID = Nova_DAL_TBase_Position.GetiPID(TBase_Position, lbl_ZoneID);
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return PID;
        }

        /// <summary>
        /// 根据库区号、巷道号获取货位状态图案视图表
        /// xgw add for  解决视图加载卡
        /// </summary>
        /// <param name="lbl_ZoneID"></param>
        /// <param name="lbl_LaneNo"></param>
        /// <returns></returns>
        public DataTable DTableTBase_PositionZoneIDPosImg(string lbl_ZoneID, string lbl_LaneNo,int subArea)
        {
            DataTable myTable = new DataTable();
            try
            {
                myTable = Nova_DAL_TBase_Position.DTableTBase_PositionZoneIDPosImg(lbl_ZoneID, lbl_LaneNo, subArea);
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return myTable;

        }


        /// <summary>
        /// 人工后备操作 托盘放入立库目标货位
        /// </summary>
        /// <param name="Tray_ID"></param>
        /// <param name="Pos_ID"></param>
        /// <param name="UserName"></param>
        /// <param name="strMessage"></param>
        /// <returns>-1:失败 1：成功</returns>
        public int TrayPosAdd_ManBackUp(string Tray_ID, long Pos_ID, string UserName, out string strMessage)
        {
            return Nova_DAL_TBase_Position.TrayPosAdd_ManBackUp(Tray_ID, Pos_ID, UserName, out strMessage);
        }

        /// <summary>
        /// 获取剩余的货位数
        /// </summary>
        /// <returns></returns>
        public int getResidueStorage()
        {
            return Nova_DAL_TBase_Position.getResidueStorage();
        }

        /// <summary>
        /// 获取已经使用的货位数
        /// </summary>
        /// <returns></returns>
        public int getUsedStorage()
        {
            return Nova_DAL_TBase_Position.getUsedStorage();
        }

        public bool UpdateByPosId(long posId, int posState)
        {
            return Nova_DAL_TBase_Position.UpdateByPosId(posId, posState);
        }

        public DataTable GetPosPrimitiveTypeList(int abc_Kind, int typeOfSize)
        {
            return Nova_DAL_TBase_Position.GetPosPrimitiveTypeList(abc_Kind, typeOfSize);
        }

    }
}
